Re: JS validations Working Fine in IE , not in Opera,firefox
[quote="rangana":2bd6yszd]Please show us the code as well as the markup involved.[/quote:2bd6yszd]
Thanks a lot rangana for responding my mail .
My Upload progarmm is working very fine in IE , I am unable to upload in firefox, opera, and safari ... The main and mandatory requirement is IE & firefox . Please help me in running in fire fox ,
1>When i am running my appication in firefox and clicking the upload button after filling the field, no action is performed and no errors are given , it is as if u are clicking the button and nothing happens
the below code is JS
[code:2bd6yszd]
function textCounter(field, countfield, maxlimit)
{
val = field.value.replace(/\|/g,'') ; //Trim Trailing White Spaces and pipe(|).
field.value=val;
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
else // otherwise, update 'characters left' counter
countfield.value = maxlimit - field.value.length;
}
function trim(str)
{
return str.replace(/^\s*|\s*$/g,"");
}
function startsWith(str1, str2)
{
return (str1.match("^"+str2)==str2);
}
function endsWith(str1, str2)
{
return (str1.match(str2+"$")==str2)
}
function validateField(loadPage)
{
var text=document.getElementsByTagName('*');
var sModule = arguments[0];
for (i=0; i <text.length; i++)
{
if(startsWith(text[i].name + "", "UN_"))
{
var req = document.getElementById("REQINFO_" + text[i].name);
if (req)
{
if (req.value == 1)
{
if (trim(text[i].value) == "")
{
alert('Please enter the fields marked with (*)');
text[i].focus();
return;
}
}
var type = document.getElementById("TYPEINFO_" + text[i].name);
{
if(type.value == "3")
{
var format = document.getElementById("TYPEINFO_" + text[i].name);
/*if(!isDate(trim(text[i].value), format.value))
{
alert("Date entered is not in the proper format");
text[i].focus();
return;
}*/
}
}
}
}
else if (text[i].name=="txtHInputFileName")
{
if(!endsWith(text[i].value + "", ".zip"))
{
alert("Only zip files are allowed.");
return ;
}
}
}
if (sModule == "load")
{
document.getElementById("btnUpload").disabled=true;
}
document.forms[0].submit();
}
function DisplayHelp(msg)
{
document.getElementById("divHelp").innerHTML=msg;
}
/*
This function used in Upload Submission Component to check the mandatory fields.
*/
function CheckForMandatory()
{
var optn = document.frmSubmissionStatus.UN_SubmissionYear.options;
var value = optn[optn.selectedIndex].value;
if(value < 1)
{
alert("Please select the Year.");
optn.focus();
return false;
}
optn = document.frmSubmissionStatus.UN_Party.options;
if(optn)
{
value = optn[optn.selectedIndex].value;
if(value < 1)
{
alert("Please select the Party.");
optn.focus();
return false;
}
}
return true;
}
[/code:2bd6yszd]
Below code is my Upload Page
[code:2bd6yszd]
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:wcm="http://filenet.com/namespaces/wcm/apps/1.0" exclude-result-prefixes="wcm" version="1.0">
<xsl:output method="html" encoding="UTF-8" omit-xml-declaration="yes" indent="yes"/>
<xsl:include href="../include/WcmProperty.xsl"/>
<xsl:variable name="TEXTAREA_MAXLENGTH" select="'250'"/>
<xsl:param name="Choice_Values"/>
<!--xsl:param name="HelpText"/-->
<xsl:param name="isPartyUser"/>
<xsl:param name="partyName"/>
<xsl:param name="selectedParty"/>
<xsl:param name="selectedSubType"/>
<xsl:param name="eventURL"/>
<xsl:param name="SucessMessage"/>
<xsl:param name="OpenPopup"/>
<xsl:template match="/">
<!--table class="popupBannerTable" align="left" width="100%" cellspacing="0" cellpadding="0" border="0"-->
<xsl:for-each select="/wcm:response/wcm:objectset/wcm:objectstore/wcm:classdesc/wcm:propdescs/wcm:propdesc">
<xsl:if test="wcm:ishidden = 0">
<xsl:if test="wcm:issysowned = 0">
<xsl:if test=" (wcm:datatype = 3) or (wcm:datatype = 4) or (wcm:datatype = 6) or (wcm:datatype = 8)">
<!--xsl:if test="not(wcm:symname='DocumentTitle')"-->
<xsl:if test="wcm:symname !='UN_sDocID'">
<tr>
<xsl:choose>
<xsl:when test="wcm:choices">
<xsl:choose>
<xsl:when test="wcm:symname='UN_Party' and $isPartyUser">
<td width="20%">
<input>
<xsl:attribute name="name"><xsl:value-of select="wcm:symname"/></xsl:attribute>
<xsl:attribute name="id"><xsl:value-of select="wcm:symname"/></xsl:attribute>
<xsl:attribute name="type"><xsl:value-of select="'hidden'"/></xsl:attribute>
<xsl:attribute name="value"><xsl:value-of select="$partyName"/></xsl:attribute>
</input>
</td>
<td width="80%"></td>
</xsl:when>
<xsl:otherwise>
<td width="20%">
<xsl:value-of select="wcm:name"/>
<xsl:if test="wcm:isvalreq = 1">
<label class="Required">*</label>
</xsl:if>
</td>
<td width="80%">
<select>
<xsl:attribute name="id"><xsl:value-of select="wcm:symname"/></xsl:attribute>
<xsl:attribute name="name"><xsl:value-of select="wcm:symname"/></xsl:attribute>
<xsl:if test="wcm:symname='UN_SubmissionType'">
<xsl:attribute name="onChange"><xsl:value-of select="$eventURL"/></xsl:attribute>
</xsl:if>
<option>---select---</option>
<xsl:for-each select=".//wcm:choice">
<xsl:choose>
<xsl:when test="../../wcm:symname='UN_SubmissionType' and contains($Choice_Values, wcm:value)">
<option>
<xsl:if test="../../wcm:symname='UN_SubmissionType'">
<xsl:if test="wcm:value=$selectedSubType">
<xsl:attribute name="selected"><xsl:value-of select="'yes'"/></xsl:attribute>
</xsl:if>
</xsl:if>
<xsl:attribute name="value"><xsl:value-of select="wcm:value"/></xsl:attribute>
<xsl:value-of select="wcm:name"/>
</option>
</xsl:when>
<xsl:when test="../../wcm:symname!='UN_SubmissionType'">
<option>
<xsl:if test="../../wcm:symname='UN_Party'">
<xsl:if test="wcm:value=$selectedParty">
<xsl:attribute name="selected"><xsl:value-of select="'yes'"/></xsl:attribute>
</xsl:if>
</xsl:if>
<xsl:attribute name="value"><xsl:value-of select="wcm:value"/></xsl:attribute>
<xsl:value-of select="wcm:name"/>
</option>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</select>
</td>
<xsl:if test="wcm:symname='UN_SubmissionType'">
<tr>
<td width="20%"></td>
<td width="80%" valign="top">
<div id="divHelp"/>
</td>
</tr>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:if test="wcm:symname ='UN_Comments'">
<td width="20%">
<xsl:value-of select="wcm:name"/>
<xsl:if test="wcm:isvalreq = 1">
<label class="Required">*</label>
</xsl:if>
</td>
<td width="80%">
<!--textarea rows="4" cols="40" onKeyDown="textCounter(this.form.UN_Comments,this.form.remLen, 250) , ray(this.form.UN_Comments,250) ;" onKeyUp="textCounter(this.form.UN_Comments,this.form.remLen, 250) , ray(this.form.UN_Comments,250) ;"-->
<textarea rows="4" cols="40" oncontextmenu="return false;" onKeyDown="textCounter(this.form.UN_Comments,this.form.remLen, 250) " onKeyUp="textCounter(this.form.UN_Comments,this.form.remLen, 250) ">
<xsl:attribute name="id"><xsl:value-of select="wcm:symname"/></xsl:attribute>
<xsl:attribute name="name"><xsl:value-of select="wcm:symname"/></xsl:attribute>
</textarea>
<label class="wcmFormText">
<xsl:value-of select="'Max:'"/>
<input readonly="1" type="text" name="remLen" size="1" maxlength="3">
<xsl:attribute name="value"><xsl:value-of select="$TEXTAREA_MAXLENGTH"/></xsl:attribute>
</input>
</label>
</td>
<tr>
<td width="20%">Select file (< 20 MB)* </td>
<td width="80%">
<input id="importFile" name="importFile" type="file" onkeydown="this.blur()" onchange="Javascript:document.getElementById('txtHInputFileName').value=document.getElementById('importFile').value"/>
</td>
</tr>
<tr>
<td width="20%"></td>
<td width="80%"><INPUT type="button" name="btnUpload" value="Upload" onclick="validateField('load')" />
</td>
</tr>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
<!--hidden fields for javascript validation-->
<input>
<xsl:attribute name="type">hidden</xsl:attribute>
<xsl:attribute name="name"><xsl:value-of select="concat('TYPEINFO_',wcm:symname)"/></xsl:attribute>
<xsl:attribute name="value"><xsl:value-of select="wcm:datatype"/></xsl:attribute>
</input>
<input>
<xsl:attribute name="type">hidden</xsl:attribute>
<xsl:attribute name="name"><xsl:value-of select="concat('REQINFO_',wcm:symname)"/></xsl:attribute>
<xsl:attribute name="value"><xsl:value-of select="wcm:isvalreq"/></xsl:attribute>
</input>
</tr>
<!--ends here-->
</xsl:if>
<!--/xsl:if-->
<!--Document title -->
</xsl:if>
</xsl:if>
</xsl:if>
</xsl:for-each>
<!--tr>
<xsl:call-template name="setTDclass">
<xsl:with-param name="position" select="position() mod 2"/>
</xsl:call-template>
<td>
<label class="Required">Select a file (< 100 MB)* </label>
</td>
<td>
<input id="importFile" name="importFile" type="file" onkeydown="this.blur()" onchange="document.getElementById('txtHInputFileName').value=document.getElementById('importFile').value"/>
</td>
</tr>
<tr>
<xsl:call-template name="setTDclass">
<xsl:with-param name="position" select="position() mod 2"/>
</xsl:call-template>
<td>
<xsl:value-of select="' '"/>
</td>
<td>
<INPUT type="button" value="Upload" onclick="validateField()"/>
<xsl:value-of select="$SucessMessage"/>
</td>
</tr>
</table-->
</xsl:template>
</xsl:stylesheet>
[/code:2bd6yszd]